<?php
/**
 *RefundController
 * @author tan bing
 * @date 2021-11-15 11:18
 */


namespace Modules\Order\Http\Controllers\Api;


use Modules\Order\Services\Api\RefundServices;

class RefundController extends ApiBaseController
{

    private RefundServices $refundServices;

    public function __construct(RefundServices $refundServices)
    {
        $this->refundServices = $refundServices;
    }

    /**
     * 订单退款浏览页面
     * @return mixed
     * @author tan bing
     * @date 2021-11-15 11:30
     */
    public function refundPreview()
    {
        try {
            $result = $this->refundServices->refundPreview();
        } catch (\Exception $e) {
            return $this->failed($e->getMessage());
        }

        return $this->success($result);
    }

    /**
     * 售后订单提交
     * @return mixed
     * @author tan bing
     * @date 2021-11-15 11:50
     */
    public function refund()
    {
        try {
            $result = $this->refundServices->refund();
        } catch (\Exception $e) {
            return $this->failed($e->getMessage());
        }

        return $this->success($result);
    }

    /**
     * @return mixed
     * @author tan bing
     * @date 2021-11-15 15:07
     */
    public function refundDetail()
    {
        try {
            $result = $this->refundServices->refundDetail();
        } catch (\Exception $e) {
            return $this->failed($e->getMessage());
        }

        return $this->success($result);
    }

    /**
     * 退货填写物流信息
     * @return mixed
     * @author tan bing
     * @date 2021-11-16 11:45
     */
    public function refundSend()
    {
        try {
            $result = $this->refundServices->refundSend();
        } catch (\Exception $e) {
            return $this->failed($e->getMessage());
        }

        return $this->success($result);
    }
}